#python作业
import random

#创建timo类
class timo:
    #定义hp，power属性
    timo_hp = 0
    timo_power = 0

    def __init__(self,timo_hp,timo_power):
        self.timo_hp = timo_hp
        self.timo_power= timo_power
    #定义fight方法
    def fight(self, police_power):
        self.timo_hp = self.timo_hp - police_power
        return self.timo_hp

#创建police类
class police:
    # 定义hp，power属性
    police_hp = 0
    police_power = 0

    def __init__(self,police_hp,police_power):
        self.police_hp = police_hp
        self.police_power = police_power
    # 定义fight方法
    def fighlt(self, timo_poewer):
        self.police_hp = self.police_hp - timo_poewer
        return self.police_hp

def main():
    #实例化hero，HP随机180~200之间，攻击随机5~15之间
    hero_hp = random.randint(180, 200)
    hero_power = random.randint(5, 15)
    hero = police(hero_hp,hero_power )
    #打印hero的血量和攻击力
    print(f"hero的血量：{hero_hp}攻击力：{hero_power}")

    #实例化enemy，HP随机180~200之间，攻击随机5~15之间
    enemy_hp = random.randint(180, 200)
    enemy_power = random.randint(5, 15)
    enemy = timo(enemy_hp,enemy_power)
    #打印enemy的血量和攻击力
    print(f"enemy的血量：{enemy_hp}攻击力：{enemy_power}")
    #进行10回合
    for i in range(1,11):
        hero_final_hp = hero.fighlt(enemy_power)
        enemy_final_hp = enemy.fight(hero_power)
        #打印每局的血量剩余情况
        print(f"第{i}回合hero剩余血量：{hero_final_hp}，enemy剩余血量：{enemy_final_hp}")
    #判断10回合后谁的血多谁获胜
    if hero_final_hp > enemy_final_hp:
            print("英雄获胜")
    elif hero_final_hp < enemy_final_hp:
            print("敌人获胜")
    elif hero_final_hp == enemy_final_hp:
            print("平局")

if __name__ == '__main__':
    main()





